<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
  <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
  <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
  <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
  <style type="text/css">

    /* tooltip */
    #tooltip{
      position:absolute;
      border:1px solid #ccc;
      background:#333;
      padding:2px;
      display:none;
      color:#fff;
    }
  </style>
</head>
<body style="margin: 0 20px">

<fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;border:0">
  <div class="layui-form-item" style="float: left;">
    <form id="form1" class="layui-form serch" action="{:url('admin/custom/index')}" method="post">
      <div class="layui-form-item" style="float: left;">


        <div class="layui-input-inline">
          <input type="text" name="username" lay-verify="title" autocomplete="off" placeholder="联系人" value="{if isset($where['goods_id'])}{$where['goods_id']}{/if}" class="layui-input layui-btn-sm">
        </div>
        <div class="layui-input-inline">
          <input type="text" name="phone" lay-verify="title" autocomplete="off" placeholder="联系电话" value="{if isset($where['goods_id'])}{$where['goods_id']}{/if}" class="layui-input layui-btn-sm">
        </div>

        <div class="layui-input-inline">
          <div class="layui-inline">
            <select name="status" lay-search="">
              <option value="">定制状态</option>
              <option value="1" {if  isset($where['classify_id']) AND $vo.classify_id==$where['classify_id']} selected{/if}>待定制</option>
              <option value="2" {if  isset($where['classify_id']) AND $vo.classify_id==$where['classify_id']} selected{/if}>定制完成</option>
            </select>
          </div>
        </div>

        <button class="layui-btn layui-btn-danger layui-btn-sm" lay-submit="" lay-filter="serch">搜索</button>
        <button type="reset" class="layui-btn layui-btn-danger layui-btn-sm clear_form">重置</button>
      </div>
    </form>

  </div>
</fieldset>

<table class="layui-table" lay-even="" lay-skin="row" lay-size="sm">
  <colgroup>
    <col width="110">
    <col width="100">
    <col width="100">
    <col width="100">
    <col width="100">
    <col width="250">
    <col width="100">
    <col width="130">
  </colgroup>
  <thead>
  <tr>
    <th>申请时间</th>
    <th>联系人</th>
    <th>电话</th>
    <th>定制类型</th>
    <th>目的地</th>
    <th>备注</th>
    <th>状态</th>
    <th>操作</th>
  </tr>
  </thead>
  <tbody>
  {volist name="data" id="vo"}
  <tr>
    <td>{$vo.createtime|date='Y-m-d',###}</td>
    <td>{$vo.username}</td>
    <td>{$vo.phoneCode}{$vo.phone}</td>
    <td>{if condition='$vo.classId eq 0'}个人定制{else}企业定制{/if}</td>
    <td>{$vo.tagName}</td>
    <td>{$vo.remarks}</td>
    <td>{if condition='$vo.status eq 1'}待定制{else}定制完成{/if}</td>
    <td>
      <a href="{:url('custom/update',['id'=>$vo.id])}"  class="layui-btn layui-btn-xs a_menu"  style="margin-right: 0;font-size:12px;">查看</a>
     {if condition='$vo.status eq 1'}
      <a codeid="{$vo.id}" class="layui-btn layui-btn-xs layui-btn-danger custom_complete"  style="margin-right: 0;font-size:12px;">定制完成</a>
      {/if}

    </td>
  </tr>
  {/volist}
  </tbody>
</table>
<div style="padding:0 20px;">{$data->render()}</div>

<script src="__PUBLIC__/layui/layui.js" charset="utf-8"></script>
<script src="__PUBLIC__/jquery/jquery.min.js"></script>
<script>
    var message;
    layui.config({
        base: '__JS__/',
        version: '1.0.1'
    }).use(['app', 'message'], function() {
        var app = layui.app,
            $ = layui.jquery,
            layer = layui.layer;
        //将message设置为全局以便子页面调用
        message = layui.message;
        //主入口
        app.set({
            type: 'iframe'
        }).init();
    });
</script>
<script type="text/javascript">

</script>
<script type="text/javascript">
    layui.use('layer', function(){
        var layer = layui.layer;
        $('.a_menu').click(function(){
            var url = $(this).attr('href');
            var a = 0;
            $.ajax({
                url:url
                ,async:false
                ,success:function(res){
                    if(res.code == 0) {
                        layer.msg(res.msg);
                        a = 1;
                    }
                }
            })
            if(a === 0) {
                layer.open({
                    type:2,
                    content:[url, 'no'],
                    area: ['700px', '600px'],
                    end:function(){
                        location.reload();
                    }
                });
            }
            return false;
        })

        $('.custom_complete').click(function(){
            var id = $(this).attr('codeid');
            layer.confirm('确定定制已完成?', function(index) {
                $.ajax({
                    url:"{:url('admin/custom/complete')}",
                    data:{id:id},
                    success:function(res) {
                        layer.msg(res.msg);
                        if(res.code == 1) {
                            setTimeout(function(){
                                location.reload();
                            },1500)
                        }
                    }
                })
            })
        })

    });
</script>
<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //常规用法
        laydate.render({
            elem: '#create_time'
        });
    });
</script>
</body>
</html>
